package com.alasbusy.alasbusyapp.utils;

import android.util.Log;

import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

/**
 * Created by Administrator on 2018/5/18.
 */

public class RegexUtils {

    public static boolean isChinaPhoneLegal(String str)
            throws PatternSyntaxException {
        //^1{1}(3{1}\\d{1}|5{1}[012356789]{1}|8{1}[0123456789]{1}|7{1}[0123678]{1})\\d{8}$"
        //String regExp = "^((13[0-9])|(15[^4])|(18[0-9])|(17[0-8])|(147,145))\\d{8}$";
        String regExp = "^((13[0-9])|(15[^4])|(18[0-9])|(17[0-8])|(14[7])|(14[5]))\\d{8}$";
        Log.e("TAG", Pattern.matches(regExp, str) + "    -------------------");
        return Pattern.matches(regExp, str);
    }

    public static boolean isPwdLegal(String str)
            throws PatternSyntaxException {
        //^1{1}(3{1}\\d{1}|5{1}[012356789]{1}|8{1}[0123456789]{1}|7{1}[0123678]{1})\\d{8}$"
        //String regExp = "^((13[0-9])|(15[^4])|(18[0-9])|(17[0-8])|(147,145))\\d{8}$";
        String regex = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,14}$";
        Log.e("TAG", Pattern.matches(regex, str) + "    -------------------");
        return Pattern.matches(regex, str);
    }
}
